package com.fand.persistent.support;

import java.util.List;
import java.util.Map;

import com.fand.dto.PaginationDto;

/**
 * 简易dao接口
 * 
 * @author yaoHT
 */
public interface DaoSupport {
	/**
	 * 生成sql
	 * 
	 * @param sqlId
	 *            sql路径
	 *            
	 * @param model
	 *            model
	 *            
	 * @return sql
	 */
	String builderSql(final String sqlId, final Map<String, Object> model);

	/**
	 * 分页
	 * 
	 * @param selectForObjectSqlId
	 *            读取sql路径
	 * 
	 * @param selectForMapListSqlId
	 *            查询sql路径
	 * 
	 * @param paginationNo
	 *            分页号
	 * 
	 * @param paginationSize
	 *            分页大小
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 分页对象
	 */
	PaginationDto<Map<String, Object>> paginationForMapList(final String selectForObjectSqlId,
			final String selectForMapListSqlId, final int paginationNo, final int paginationSize,
			final Map<String, Object> model);

	/**
	 * 分页
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param selectForObjectSqlId
	 *            读取sql路径
	 * 
	 * @param selectForMappedObjectListSqlId
	 *            查询sql路径
	 * 
	 * @param paginationNo
	 *            分页号
	 * 
	 * @param paginationSize
	 *            分页大小
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 分页对象
	 */
	<R> PaginationDto<R> paginationForMappedObjectList(final Class<R> mappedClass,
			final String selectForObjectSqlId, final String selectForMappedObjectListSqlId, final int paginationNo,
			final int paginationSize, final Map<String, Object> model);

	/**
	 * 获取
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 行字段值对象
	 */
	Map<String, Object> selectForMap(final String sqlId, final Map<String, Object> model);

	/**
	 * 查询
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 行字段值对象列表
	 */
	List<Map<String, Object>> selectForMapList(final String sqlId, final Map<String, Object> model);

	/**
	 * 获取
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 行字段值对象
	 */
	<R> R selectForMappedObject(final Class<R> mappedClass, final String sqlId, final Map<String, Object> model);

	/**
	 * 查询
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 行字段值对象列表
	 */
	<R> List<R> selectForMappedObjectList(final Class<R> mappedClass, final String sqlId,
			final Map<String, Object> model);

	/**
	 * 读取
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param readFieldId
	 *            读取字段标识
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 字段值
	 */
	<R> R selectForObject(final Class<R> requiredType, final String sqlId, final String readFieldId,
			final Map<String, Object> model);

	/**
	 * 读取
	 * 
	 * @param elementType
	 *            返回类型
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param objectId
	 *            读取字段标识
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 字段值列表
	 */
	<R> List<R> selectForObjectList(final Class<R> elementType, final String sqlId, final String objectId,
			final Map<String, Object> model);

	/**
	 * 更新
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param modelList
	 *            modelList
	 * 
	 * @return 影响行数
	 */
	int update(final String sqlId, final List<Map<String, Object>> modelList);

	/**
	 * 更新
	 * 
	 * @param sqlId
	 *            sql路径
	 * 
	 * @param model
	 *            model
	 * 
	 * @return 影响行数
	 */
	int update(final String sqlId, final Map<String, Object> model);
}